package JLB_Chapter_07;

import java.util.Random;

public class FinalStaticData {
    private static Random rand = new Random();
    private final int a1 = rand.nextInt(10);
    private static final int a2 = rand.nextInt(10);
    private static int a3 = rand.nextInt(10);
    public static void main(String[] args){
        FinalStaticData fdata = new FinalStaticData();
        // 调用定义为final的al
        System.out.println("重新实例化对象调用a1的值:" + fdata.a1);
        // 调用定义为static final的a2
        System.out.println("重新实例化对象调用a2的值:" + fdata.a2);
        System.out.println("重新实例化对象调用a3的值:" + fdata.a3);
        fdata.a3 = 100;
        System.out.println("调用a3的值:" + fdata.a3);
        // 实例化另外一个对象
        FinalStaticData fdata2 = new FinalStaticData();
        System.out.println("重新实例化对象调用a1的值:" + fdata2.a1);
        System.out.println("重新实例化对象调用a2的值:" + fdata2.a2);
        System.out.println("重新实例化对象调用a3的值:" + fdata2.a3);
        fdata2.a3 = 1000;
        System.out.println("调用a3的值:" + fdata2.a3);
    }
}
